#@embedLayout()


#define content()

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">

        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'west',split:true,iconCls:'icon-application_view_columns',border:false"
                 style="width:50%;">
                <div id="equipmentDatagridIdForbid"></div>
            </div>
            <div data-options="region:'center',split:false,iconCls:'icon-application_view_columns',border:false"
                 style="width:50%;">
                <div id="equipmentForbidDatagridIdForbid"></div>
            </div>
        </div>


        <div id="equipmentTbForbid" style="padding: 5px;">
            <div class="row">
                <div class="col-md-12">
                    <form id="equipmentTbForbidSearchForm">
                        <div class="easyui-panel" style="width:100%;padding:10px;"
                             data-options="iconCls:'icon-application_form'">

                            厂商： <input id="equipmentVenId" class="easyui-combobox" style="width: 250px;"
                                       data-options="
                    valueField: 'ven_id',
                    textField: 'vendor_alias',
                    editable:false,
                    url: '#(ctx)/equipment/findVendorList'">

                            &nbsp;&nbsp;

                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="equipmentDatagridIdForbidDatagridQuery();"
                               iconCls="icon-zoom">#(_res.get('system.common.search'))</a>
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="$('#equipmentTbForbidSearchForm').form('clear');"
                               iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>
                        </div>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12" style="margin-top: 5px;">
                    <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true" iconCls="icon-shape_move_forwards" id="addEquipmentToForbid">添加厂商型号版本</a>
                </div>
            </div>
        </div>

        <div id="equipmentForbidTbForbid" style="padding: 5px;">
            <div class="row">
                <div class="col-md-12">
                    <form id="equipmentForbidTbForbidSearchForm">
                        <div class="easyui-panel" style="width:100%;padding:10px;"
                             data-options="iconCls:'icon-application_form'">

                            厂商： <input id="equipmentForbidVenId" class="easyui-combobox" style="width: 250px;"
                                       data-options="
                                            valueField: 'ven_id',
                                            textField: 'vendor_alias',
                                            editable:false,
                                            url: '#(ctx)/equipment/findVendorList'">

                            &nbsp;&nbsp;

                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="equipmentForbidDatagridIdForbidDatagridQuery();"
                               iconCls="icon-zoom">#(_res.get('system.common.search'))</a>
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="$('#equipmentForbidTbForbid').form('clear');"
                               iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>
                        </div>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12" style="margin-top: 5px;">
                    <a href="javascript:;" id="removeEquipmentToForbid" data-options="plain:true" iconCls="icon-shape_move_forwards" class="easyui-linkbutton">移除厂商型号版本</a>
                </div>
            </div>
        </div>
    </div>
</div>

#end


#define css()


#end


#define js()

<script type="text/javascript">

    var equipmentDatagridIdForbid = 'equipmentDatagridIdForbid',
        equipmentForbidDatagridIdForbid = 'equipmentForbidDatagridIdForbid',
        equipmentTbForbid = 'equipmentTbForbid', equipmentForbidTbForbid = 'equipmentForbidTbForbid';

    $(function () {

        //初始化表格
        $("#" + equipmentDatagridIdForbid).datagrid({
            url: contextRootPath + '/equipment/findListForPaginateNotInForbid',
            rownumbers: true,
            pageSize: 30,
            title: '厂商型号版本列表',
            iconCls: 'icon-application_form',
            toolbar: '#' + equipmentTbForbid,
            border: true,
            singleSelect: false,
            nowrap: false,
            striped: true,
            fit: true,
            pagination: true,
            fitColumns: true,
            columns: [[
                {
                    field: DBConts.TABLE_VENDOR.VEN_ID,
                    title: DBConts.TABLE_VENDOR.VEN_ID,
                    width: 100,
                    checkbox: true
                },
                {
                    field: DBConts.TABLE_VENDOR.VENDOR_ALIAS,
                    title: '厂商别名',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_VENDOR.VENDOR_NAME,
                    title: '厂商名称',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_EQUIPMENT.EQU_MODEL,
                    title: '设备型号',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value === null || value === '') return 'ALL';
                        else return value;
                    }
                },
                {
                    field: DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION,
                    title: '设备型号版本',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value === null || value === '') return 'ALL';
                        else return value;
                    }
                }
            ]]
        });

        //初始化表格
        $("#" + equipmentForbidDatagridIdForbid).datagrid({
            url: contextRootPath + '/equipment/findEquipmentForbidListForPaginate',
            rownumbers: true,
            pageSize: 30,
            title: '黑名单',
            iconCls: 'icon-application_form',
            border: true,
            toolbar: '#' + equipmentForbidTbForbid,
            singleSelect: false,
            nowrap: false,
            striped: true,
            fit: true,
            pagination: true,
            fitColumns: true,
            columns: [[
                {
                    field: DBConts.TABLE_EQUIPMENT_FORBID.EA_ID,
                    title: DBConts.TABLE_EQUIPMENT_FORBID.EA_ID,
                    width: 100,
                    checkbox: true
                },
                {
                    field: DBConts.TABLE_VENDOR.VENDOR_ALIAS,
                    title: '厂商别名',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_VENDOR.VENDOR_NAME,
                    title: '厂商名称',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_EQUIPMENT.EQU_MODEL,
                    title: '设备型号',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value === null || value === '') return 'ALL';
                        else return value;
                    }
                },
                {
                    field: DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION,
                    title: '设备型号版本',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value === null || value === '') return 'ALL';
                        else return value;
                    }
                }
            ]]
        });


        $("#addEquipmentToForbid").on('click', function () {
            var selections = $('#' + equipmentDatagridIdForbid).datagrid('getSelections');
            var equIds = "";
            var venIds = "";
            var equVerIds = "";
            var equModels = "";
            var vendorNames = "";
            var equVersions = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的厂商型号版本!", "warning");
                return;
            }

            $.each(selections, function (i, v) {
                venIds += v[DBConts.TABLE_EQUIPMENT.VEN_ID] + ",";
                if (v[DBConts.TABLE_EQUIPMENT.EQU_ID] === null){
                    equIds += "#(com.gmrz.uap.common.ConditionConst::CONDITTION_FORBID_EQUID),";
                }
                if(v[DBConts.TABLE_EQUIPMENT.EQU_ID] !== null){
                    equIds += v[DBConts.TABLE_EQUIPMENT.EQU_ID] + ",";
                }
                if (v[DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION_ID] === null){
                    equVerIds += "#(com.gmrz.uap.common.ConditionConst::CONDITTION_FORBID_EQUVERSIONID),";
                }
                if(v[DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION_ID] !== null){
                    equVerIds += v[DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION_ID] + ",";
                }

                equModels += v[DBConts.TABLE_EQUIPMENT.EQU_MODEL] + ",";
                vendorNames += v[DBConts.TABLE_VENDOR.VENDOR_ALIAS] + ",";
                equVersions += v[DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION] + ",";
            });

            var params = {
                "equIds": equIds,
                "venIds": venIds,
                "equVerIds": equVerIds,
                "equModels": equModels,
                "vendorNames": vendorNames,
                "equVersions": equVersions
            };

            $.post(contextRootPath + "/equipment/equipmentForbidSave", params, function (data) {
                $.messager.alert("提示", data.message, 'info', function () {
                    $("#" + equipmentDatagridIdForbid).datagrid("reload");
                    $("#" + equipmentForbidDatagridIdForbid).datagrid("reload");
                });
            }, 'json');
        });


        $("#removeEquipmentToForbid").on('click', function () {
            var selections = $('#' + equipmentForbidDatagridIdForbid).datagrid('getSelections');
            var ids = "";
            var vendorNames = "";
            var equModels = "";
            var equVersions = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的厂商型号版本!", "warning");
                return;
            }

            $.each(selections, function (i, v) {
                ids += v[DBConts.TABLE_EQUIPMENT_FORBID.EA_ID] + ",";
                vendorNames += v[DBConts.TABLE_VENDOR.VENDOR_ALIAS] + ",";
                equModels += v[DBConts.TABLE_EQUIPMENT.EQU_MODEL] + ",";
                equVersions += v[DBConts.TABLE_EQUIPMENT_VERSION.EQU_VERSION] + ",";
            });

            var params = {
                "ids": ids,
                "vendorNames": vendorNames,
                "equModels": equModels,
                "equVersions": equVersions
            };

            $.post(contextRootPath + "/equipment/equipmentForbidRemove", params, function (data) {
                $.messager.alert("提示", data.message, 'info', function () {
                    $("#" + equipmentDatagridIdForbid).datagrid("reload");
                    $("#" + equipmentForbidDatagridIdForbid).datagrid("reload");
                });
            }, 'json');
        });

    });


    function equipmentDatagridIdForbidDatagridQuery() {
        var equipmentVenId = $("#equipmentVenId");

        var flag = $("#searchForm").form('enableValidation').form('validate');

        if (!flag) return;

        $("#" + equipmentDatagridIdForbid).datagrid({
            queryParams: {
                "equipment.ven_id": equipmentVenId.combobox("getValue")
            }
        });
    }


    function equipmentForbidDatagridIdForbidDatagridQuery() {
        var equipmentForbidVenId = $("#equipmentForbidVenId");

        var flag = $("#searchForm").form('enableValidation').form('validate');

        if (!flag) return;

        $("#" + equipmentForbidDatagridIdForbid).datagrid({
            queryParams: {
                "equipmentForbid.ven_id": equipmentForbidVenId.combobox("getValue")
            }
        });
    }
</script>

#end


